package icu.sehnen.service.impl;

import icu.sehnen.dao.UserDao;
import icu.sehnen.dao.impl.UserDaoImpl;
import icu.sehnen.model.UserModel;
import icu.sehnen.service.UserService;

public class UserServiceImpl implements UserService {


    @Override
    public String login(UserModel userModel, String sessionCode) {
//        判断验证是否正确
        UserDao userDao = new UserDaoImpl();

        Boolean isHasUser = userDao.findUser(userModel);

        if (!sessionCode.equals(userModel.getCode())){
            return  "code_error";
        }

        if (isHasUser ) {
            return "success";
        }
        return "false";
    }

    @Override
        public String register(UserModel userModel) {

        UserDao userDao = new UserDaoImpl();
        Boolean isSucces=userDao.addUser(userModel);
        if(isSucces){
            return "success";

        }
        return "failed";

    }


}
